package d.max.rwp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import d.max.rwp.action.NavigateActivityAction;
import d.max.rwp.ui.NavigateDashboardListener;

/**
 * author: Maxim Dybarskiy
 * date:   Sep 3, 2011
 * time:   6:45:29 PM
 */
public class HomeActivity extends Activity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.home);
        
        // set navigate actions
        setNavigateListener(R.id.actionbutton_clock, SettingsActivity.SCREEN_CLOCK);
        setNavigateListener(R.id.actionbutton_list, SettingsActivity.SCREEN_FILES);
        setNavigateListener(R.id.actionbutton_help, SettingsActivity.SCREEN_HELP);
    }
    
    private void setNavigateListener(int id, String screen) {
        View view =  findViewById(id);
        if (view != null) {
            view.setOnClickListener(new NavigateDashboardListener(
                new NavigateActivityAction(this, new Intent(this, SettingsActivity.class).
                putExtra("screen", screen))));
        }
    }
}
